package com.umeox.zikrringtest

import android.annotation.SuppressLint
import android.bluetooth.BluetoothAdapter
import android.bluetooth.BluetoothManager
import android.content.Context
import android.content.Intent
import android.location.LocationManager
import android.net.Uri
import android.provider.Settings

fun Context.intoSetting() {
    val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
    intent.data = Uri.parse("package:$packageName")
    startActivity(intent)
}

fun Context.getGPSStatus(): Boolean {
    val locationManager = getSystemService(Context.LOCATION_SERVICE) as LocationManager
    return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER) ||
            locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)
}

fun Context.getBluetoothStatus(): Boolean {
    val manager = getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager
    return manager.adapter.isEnabled
}

@SuppressLint("MissingPermission")
fun Context.setBluetoothStatus(status: Boolean) {
    val manager = getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager
    if (status) {
        manager.adapter.enable()
    } else {
        manager.adapter.disable()
    }
}